package top.lingchen.blogapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lingchen.blogapi.service.TagService;
import top.lingchen.blogapi.vo.Result;

/**
 * @Author 凌宸
 * @create 2021-12-16 下午 3:18
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping("/tags")
public class TagsController {
    @Autowired
    private TagService tagService;

    // 访问路径 /tags/hot
    @GetMapping("/hot")
    public Result getHots(){
        int limit = 6; // 最热标签限制数
        return tagService.hots(limit);
    }

    @GetMapping
    public Result getAllTags(){
        return tagService.findAll();
    }

    @GetMapping("/detail")
    public Result getAllTagsDetail(){
        return tagService.getAllTagsDetail();
    }

    @GetMapping("/detail/{id}")
    public Result getTagsDetailById(@PathVariable("id") Long tagId){
        return tagService.getTagsDetailById(tagId);
    }

}
